<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>15.城市选择案例</title>
</head>
    <style>
        select {
            width: 200px;
            background-color: #FF99CC;
            height: 200px;
            font-size: 20px;
        }
        .btn-box {
            width: 30px;
            display: inline-block;
            vertical-align: top;
        }
    </style>
<body>
    <h1>城市选择：</h1>
    <select id="src-city" name="src-city" multiple>
        <option value="1">北京</option>
        <option value="2">上海</option>
        <option value="3">深圳</option>
        <option value="4">广州</option>
        <option value="5">西红柿</option>
    </select>
    <div class="btn-box">
        <button id="btn1">&gt;&gt;</button>
        <button id="btn2">&lt;&lt;</button>
        <button id="btn3">&gt;</button>
        <button id="btn4">&lt;</button>
    </div>
    <select id="tar-city" name="tar-city" multiple></select>
    

    <script src="../jquery-3.2.1.js"></script>
    <script>
        
        $(function(){
            $("#btn1").click(function(){// 全选的添加过去
                $("#src-city>option").appendTo("#tar-city")
            });
            $("#btn2").click(function(){
                $("#tar-city>option").appendTo("#src-city")
            });
            $("#btn3").click(function(){ // 选中的添加过去
                $("#src-city>option:selected").appendTo("#tar-city")
            });
            $("#btn4").click(function(){
                $("#tar-city>option:selected").appendTo("#src-city")
            });
        });
        
    </script>
</body>
</html>